package com.starter.home.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.starter.home.domain.entity.Tags;
import com.starter.home.dao.TagsDao;
import com.starter.home.service.ITagsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author
 * @since 2020-05-04
 */
@Service
public class TagsServiceImpl extends ServiceImpl<TagsDao, Tags> implements ITagsService {

    @Override
    public List<String> getTags(Integer userId) {
        QueryWrapper<Tags> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id",userId);
        List<Tags> tags = this.getBaseMapper().selectList(queryWrapper);
        List<String> collect = tags.stream().map(Tags::getTagName).collect(Collectors.toList());
        return collect;
    }
}
